package leecode

import (
	"strconv"
	"strings"
)

func maximum69Number(num int) int {
	//把最靠前的6反转为9
	numStr := strconv.Itoa(num)
	arr := strings.Split(numStr, "")
	for i := 0; i < len(arr); i++ {
		if arr[i] == "6" {
			arr[i] = "9"
			break
		}
	}
	//合并
	resultStr := strings.Join(arr, "")
	result, _ := strconv.Atoi(resultStr)
	return result
}
